Repository navigation
Extend options arg to support custom model definitions - #96
shlomiassaf wants to merge 2 commits into
Conversation
* Added the ability to "extend" models-config (choose overwrite/extend)
|
Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test." |
|
Example:
If no sourceFile supplied, a search is made in modelDefinitions.sourceDir, the filename is the the lowercase value of TODO: set the Basename to a dasherize name instead of lowercase. when setting
|
When a models object is added to the options with and explicit "__extend" = false it would skip deletion of the property. moving the delete instruction will fix it.
|
@shlomiassaf thank you for the pull request. It is very unclear to me what problem (use-case) are you trying to solve? My initial impression is that you are making things too complex and thus I am inclining to reject this patch. |
|
This is an issue/enhancement you opened, as stated in my 1st comment: SEE #49 The use case is very clear, allow loading models using the model definition schema but not from a file, from an object. |
|
I see, thanks for the explanation. I'll review the patch with that use case in mind. |
|
@slnode test please |
|
This patch seems to either implement a different thing, or else it is adding much more features beyond simple "custom model definitions". Let's split the work into multiple small incremental pull requests, so that I can review each new feature in isolation. Please start with the feature "allow the developer to supply custom model definitions to replace the result of findModelDefinitions" and add a unit-test to demonstrate & verify the new functionality. |
|
I understand what you mean. A quick question, The code as is now, does not allow loading If a user wants to generate models from database, remote call or any other external source, he will be able to do it but he will have to give up the built-in models. The solution in my PR enables loading them without skipping the |
Yes.
The built-in models are always defined created by loopback, you should not include them in model definitions passed to loopback-boot. Just reference them in Even if that was not the case, the definition of built-in models can be easily reconstructed: {
User: {
definition: require('loopback/common/models/user.json'),
sourceFile: require.resolve('loopback/common/models/user.js')
}
} |
See #49